package c.x.jy.wexin.controller;

import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.RechargeEntity;
import c.x.jy.service.service.RechargeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 会员充值计划
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-26 13:59:59
 */
@RestController
@RequestMapping("wechat/recharge")
public class RechargeController {
    @Autowired
    private RechargeService rechargeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = rechargeService.queryPage(params);

        return R.put(page);
    }


    @RequestMapping("/all")
    public R all(){
        List<RechargeEntity> page = rechargeService.all();

        return R.put(page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:recharge:info")
    public R info(@PathVariable("id") Long id){
		RechargeEntity recharge = rechargeService.getById(id);

        return R.put(recharge);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:recharge:save")
    public R save(@RequestBody RechargeEntity recharge){
		rechargeService.save(recharge);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:recharge:update")
    public R update(@RequestBody RechargeEntity recharge){
		rechargeService.updateById(recharge);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("business:recharge:delete")
    public R delete(@PathVariable("id") Long id){
		rechargeService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

